/*--------------------------------------------------------------------------------*/
#ifndef __ARRAY__
#define __ARRAY__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
/*--------------------------------------------------------------------------------*/
template< typename _CLASS_ >
class ARRAY
{

public:

    // .. TYPES


    // .. CONSTRUCTORS

    ARRAY() : Vector()//, ItemCount( 0 )
    {
    }

    ~ARRAY()
    {
    	/*
    	if( Vector )
    	{
    		delete []Vector;
    	}*/
    }

    // .. METHODS

    VOID Add( const _CLASS_ & item )
    {
    	Vector.push_back( item );
    }

    VOID Clear()
    {
        Vector.clear();
    }

    VOID SetItemCount( const COUNT count )
    {
    	//ItemCount = count;
        Vector.resize( count );
    	//Vector = new _CLASS_ [ count ];
    }

    BOOL HasItem( const _CLASS_ & item )
    {
    	INDEX
			index;

    	for( index = 0; index < GetItemCount(); ++index )
    	{
    		if( Vector[ index ] == item )
    		{
    			return true;
    		}
    	}

    	return false;
    }

    VOID ReserveItemCount( const COUNT count )
    {
    	Vector.reserve( count );
    }

    COUNT GetItemCount() const
    {
    	//return ItemCount;
        return (COUNT)Vector.size();
    }

    _CLASS_ *GetArray()
    {
    	return ( _CLASS_ * )&Vector[0];
    	//return Vector;
    }

    VOID Sort( BOOL ( *compare_method ) )
    {
    	sort( Vector.begin(), Vector.end(), compare_method );
    }

    // .. OPERATORS

    _CLASS_ & operator[]( const INDEX item_index )
    {
        return Vector[ item_index ];
    }

    const _CLASS_ & operator[]( const INDEX item_index ) const
    {
        return Vector[ item_index ];
    }
    
    ARRAY< _CLASS_ > & operator+( ARRAY< _CLASS_ > & other )
    {
    	Vector.insert( Vector.end(), other.Vector.begin(), other.Vector.end() );
    	return *this;
    }

	ARRAY< _CLASS_ > & operator+=( ARRAY< _CLASS_ > & other )
    {
    	Vector.insert( Vector.end(), other.Vector.begin(), other.Vector.end() );
    	return *this;
    }

private:

    // .. ATTRIBUTES

    vector<_CLASS_> Vector;
//    _CLASS_
//		*Vector;
//    COUNT
//		ItemCount;

};
/*--------------------------------------------------------------------------------*/
#endif


